/**
 * 
 */
package com.evon.yardmanagement.transformer;


import com.evon.yardmanagement.model.Section;
import com.evon.yardmanagement.model.Yard;
import com.evon.yardmanagement.ui.dto.SectionDTO;


/**
 * @author Sandeep
 * 
 */
public class SectionTransformer {
	static BaseTransformer<Section, SectionDTO> transformer = new BaseTransformer<Section, SectionDTO>(
			Section.class, SectionDTO.class);


	public static Section transformCreateSection(SectionDTO sectionDto) {


		Section section = new Section();
		Yard yard = new Yard();
		yard.setId(sectionDto.getYardDTO().getId());
		section.setYard(yard);
		// section.setId(sectionDto.getSectionId());
		section.setName(sectionDto.getSectionName());
		section.setIsPermanent(sectionDto.getPermanent() ? 1 : 0);
		section.setIsActive(sectionDto.isActive() ? 1 : 0);
		section.setCapacity(sectionDto.getCapacity());


		return section;
	}


	public static SectionDTO transformToDTO(Section section) {
		return transformer.transformToDTO(section);
//		SectionDTO sectionDTO = new SectionDTO();
//		/*
//		* Yard yard = new Yard(); yard.setId(10); section.setYard(yard);
//		*/
//		// section.setId(sectionDto.getSectionId());
//		sectionDTO.setSectionName(section.getName());
//		sectionDTO.setPermanent(section.getIsPermanent() == 1 ? true : false);
//		sectionDTO.setActive(section.getIsActive() == 1 ? true : false);
//		sectionDTO.setCapacity(section.getCapacity());
//		sectionDTO.setSectionId(section.getId());
//		return sectionDTO;
	}
	public static Section transformToModel(SectionDTO sectionDTO) {
		return transformer.transformToModel(sectionDTO);
	}
}